{% extends 'layouts/master-page.html' %}
{% block title %} Admin listmanagement {% endblock %}
{% block head %}
<!-- css -->
  <link href="/static/css/custom/admin.css" rel="stylesheet" />

  <script type="text/javascript" src="/static/js/custom/list.js"></script>
  <script type="text/javascript" src="/static/js/custom/listmanagement.js"></script>
{% endblock %}
{% block content %}
  <!-- breadcrumb -->
{% include 'subpages/breadcrumbs.html' %}
  <!-- vendor/product/version -->
  <table class="table table-hover table-striped">
    <thead class="thead-dark">
      <tr class="warning">
        <th colspan="3">
          {% if version != None%}
            Versions for {{ vendor }} {{ product|htmlDecode }}
          {% elif product != None %}
            Products for {{ vendor|htmlDecode }}
          {% elif product == None %}
            Vendors
          {% endif %}
        </th>
      </tr>
    </thead>
    <tbody>
      {% if version != None %}
        {% for v in version %}
          <tr>
            <td>{{ product|htmlDecode }} {{ v|htmlDecode }}</td>
            <!-- explanation of double "encoding": javascript likes to decode our encoded string, so this way, we still have an encoded string -->
            <td><a href="javascript:addCPE('whitelist','{{vendor|htmlEncode}}:{{ product|htmlEncode|htmlEncode }}:{{ v }}')"><i class="far fa-eye"></i> whitelist</a></td>
            <td><a href="javascript:addCPE('blacklist','{{vendor|htmlEncode}}:{{ product|htmlEncode|htmlEncode }}:{{ v }}')"><i class="far fa-eye-slash"></i> blacklist</a></td>
          </tr>
        {% endfor %}
      {% elif product != None %}
        {% for p in product %}
          <tr>
            <td><a href="/admin/listmanagement/{{ vendor }}/{{ p}}">{{ p|htmlDecode }}</a> </td>
            <td><a href="javascript:addCPE('whitelist','{{vendor|htmlEncode}}:{{ p|htmlEncode }}')"><i class="far fa-eye"></i> whitelist</a></td>
            <td><a href="javascript:addCPE('blacklist','{{vendor|htmlEncode}}:{{ p|htmlEncode }}')"><i class="far fa-eye-slash"></i> blacklist</a></td>
          </tr>
        {% endfor %}
      {% else  %}
        {% for v in vendor %}
          <tr>
            <td><a href="/admin/listmanagement/{{ v}}">{{ v|htmlDecode }}</a></td>
            <td><a href="javascript:addCPE('whitelist','{{ v|htmlEncode }}')"><i class="far fa-eye"></i> whitelist</a></td>
            <td><a href="javascript:addCPE('blacklist','{{ v|htmlEncode }}')"><i class="far fa-eye-slash"></i> blacklist</a></td>
          </tr>
        {% endfor %}
      {% endif %}
    </tbody>
  </table>
{% endblock %}
